package com.kk.permission.utils;

import android.content.Context;

import java.util.ArrayList;

public class BaseUtil {
//    private static RequestConfig sConfig;
    private static IAdapter sInst;

    public interface IAdapter {
        Context getAppContext();

        String getChannelCode();

        String getLoginSecret();

//        LooopRequestConfig getLooopConfig();

//        RequestConfigBuilder getRequestConfigBuilder();

        String getSimPhoneNumber();

        ArrayList<String> getWS2ProxyAddress();

        boolean isDebugMode();

        boolean isDebugServer();

        boolean isStrictDebugMode();
    }

    public static void init(IAdapter iAdapter) {
        sInst = iAdapter;
    }

    public static IAdapter getAdapter() {
        if (sInst != null) {
            return sInst;
        }
        throw new IllegalStateException("BaseUtil adapter was not initialized");
    }

    public static Context getAppContext() {
        if (sInst != null) {
            return sInst.getAppContext();
        }
        throw new IllegalStateException("BaseUtil adapter was not initialized");
    }

    public static boolean isDebugMode() {
        if (sInst != null) {
            return sInst.isDebugMode();
        }
        throw new IllegalStateException("BaseUtil adapter was not initialized");
    }

//    public static RequestConfig getRequestConfig() {
//        if (sConfig == null) {
//            synchronized (BaseUtil.class) {
//                if (sConfig == null) {
//                    sConfig = getAdapter().getRequestConfigBuilder().build();
//                }
//            }
//        }
//        if (sConfig != null) {
//            return sConfig;
//        }
//        throw new IllegalArgumentException("BaseUtil request config should be initialized");
//    }
}
